package com.itheima.stream;

import com.itheima.domain.Student;

import java.util.*;
import java.util.stream.Stream;

/*
获取流操作
 */
public class Demo01 {


    public static void main(String[] args) {
        //Collection  .steam()
        ArrayList<String> list = new ArrayList<>(List.of("鹿晗", "黄子韬", "张艺兴", "张艺兴"));
        Stream<String> stream = list.stream();
       //System.out.println(stream);
        stream.forEach(s-> System.out.println(s));
        HashSet<String> set = new HashSet<>(Set.of("鹿晗", "黄子韬", "张艺兴"));
        set.stream().forEach(s -> System.out.println(s));
        //Map -> Set  .steam()
        HashMap<String, String> map = new HashMap<>(Map.of("小璐", "PGone", "马蓉", "宋喆", "爽子", "张恒"));
        map.keySet().stream().forEach(k-> System.out.println(k));
        map.entrySet().stream().forEach(entry-> System.out.println(entry.getKey()+"===="+entry.getValue()));

        //数组  Arrays.stream()
        int[] arr={11,22,33,44,55};
        Arrays.stream(arr).forEach(i-> System.out.println(i));

        //相同类型的多个数据  Stream.of
        Student cai = new Student("蔡徐坤", 26);
        Student wu = new Student("吴亦凡", 31);
        Student tu = new Student("小土豆", 50);
        Student zhou = new Student("周杰伦", 40);
        Stream<Student> stuStream = Stream.of(cai, wu, tu, zhou);
        stuStream.forEach(s-> System.out.println(s));





    }
}
